
********************************************************************************
*
*	Understanding the Impact of US Military Service on Support for Insurrection
*   Journal of Conflict Resolution
*   Replication
*
*   Robert A. Pape
*	Keven G. Ruby   
*	Kyle D. Larson
*   Kentaro Nakamura
*
*	variable transformations used in all dofiles
*   
*   v2024-05-29
*
********************************************************************************

* Load data
use vetstudy_jcr.dta, clear


	
// Insurrectionist Sentiments Index

alpha force force_personal, casewise ///
	gen(insurrection_index)			   

// Authoritarianism Index 

alpha value_elders value_obedience value_manners, ///
	gen(authoritarianism) casewise
	
//Religiosity Index

alpha relig_pray relig_services relig_life, ///
	gen(religiosity) casewise 	

// Conspiracy Index

alpha conspiracy_qanon conspiracy_jailpatriots conspiracy_demreplacement, ///
	gen(conspiracy) casewise 
	
// Polarization Measure
					 
gen polarization = favor_trump - favor_biden // Positive Values = Pro-Trump
		
label define plabel -4 "Strong D Partisan" 0 "Non-Partisan" 4 "Strong R Partisan", replace
label values polarization plabel		

// race4
recode racethnicity (1=1 "White") /// Group small racial and ethnic 
					(2=2 "Black") /// categories into other 
					(4=3 "Hispanic") ///
					(3 5 6 = 4 "Other"), gen(race4)


** Binary variables
					
// Controlls 
gen b_insurrect = cond(insurrection_index>3,1,0)
	replace b_insurrect = . if missing(insurrection_index)	
gen b_male 				= cond(gender==1, 1, 0)
	replace b_male = . if missing(gender)
gen b_under35 			= cond(age<36, 1, 0)
	replace b_under35 = . if missing(age)
gen b_christian 		= cond(relig<5 | relig==12, 1, 0)
	replace b_christian = . if missing(relig)
gen b_authoritarian		= cond(authoritarianism==2,1,0)	
	replace b_authoritarian = . if missing(authoritarianism)
gen b_religious 		= cond(religiosity>4 & !missing(religiosity),1,0) 
	replace b_religious = . if missing(religiosity)
gen b_childlaw 			= cond(childlaw>3 & !missing(childlaw),1,0)
	replace b_childlaw = . if missing(childlaw)
gen b_white 			= cond(race4 == 1, 1, 0)
	replace b_white = . if missing(race4)
gen b_republican 		= cond(partyid3==3, 1, 0)
	replace b_republican = . if missing(partyid3)
gen b_independent 		= cond(partyid3==2, 1, 0)
	replace b_independent = . if missing(partyid3)
gen b_democrat 		= cond(partyid3==1, 1, 0)
	replace b_democrat = . if missing(partyid3)
	
// No Bachelors Degre 
gen b_nocollege			= cond(educ5<4, 1, 0)
	replace b_nocollege = . if missing(educ5)

// Mediators
gen b_conspiracy 		= cond(conspiracy>=3.5,1,0) // high conspiracy beliefs
	replace b_conspiracy = . if missing(conspiracy)
gen b_polarization		= cond(polarization>2,1,0)	// strong R partisan  
	replace b_polarization = . if missing(polarization)

	
// Post-Treatment Control Binaires**********************************************

gen b_econconcern 		= cond(econconcern>3,1,0)
	replace b_econconcern = . if missing(econconcern)
gen b_hardship			= cond(hardship==2,1,0)
	replace b_hardship = . if missing(b_hardship)
	
* Military-Specific Variables **************************************************

* Only available for Veteran==1
* Set veterans missing data to missing 
* Set non-veterans to zero (cannot have the factor)


// Served During GWoT (Binary)
gen year_joined = msr1 + 1974 		// Transform from labels to years 
	replace year_joined = 	. if missing(msr1) | veteran == 0

gen year_left = year_joined + msr5	// Calculated year departed 
	replace year_left = 	. if missing(msr1) | missing(msr5) | veteran == 0
	
gen b_servedgwot = .
	replace b_servedgwot = 0 if veteran == 1
	replace b_servedgwot = 1 if year_joined >= 2001 & !missing(year_joined)
	replace b_servedgwot = 1 if year_left >= 2001 & !missing(year_left)
	replace b_servedgwot = . if missing(year_joined)

// Served Only One Tour or Less, i.e. <=4 years (Binary) 
gen b_singletour = . 
	replace b_singletour = 0 if msr5 > 4
	replace b_singletour = 1 if msr5 < 5 
	replace b_singletour = . if missing(msr5) | veteran==0
	
// Deployed to Combat Area (Binary)
gen b_combatdeployment = 0
	replace b_combatdeployment = 1 if msr8 > 0
	replace b_combatdeployment = . if msr8 == 998 | missing(msr8) | veteran==0

// Involuntary Discharge (Binary)
gen b_discharged = .
	replace b_discharged = cond(msr9 == 1,1,0)
	replace b_discharged = . if missing(msr9) | veteran==0
	
// Combat Trauma (Index --> Binary)
alpha combat mortalfear sawfriendkilled sawenemykilled sawcivskilled, ///
	gen(combattrauma) casewise

gen b_combattrauma = . 	// Generate Binary 
	replace b_combattrauma = 1 if combattrauma > 1 
	replace b_combattrauma = 0 if combattrauma == 1
	replace b_combattrauma = . if missing(combattrauma) | veteran == 0

// Post-service experiences

* for the following, we count as b_var==1 somewhat disagree (2) to strongly agree (5)

foreach var of varlist reintegration disillusioned unappreciated ptsd {
		
	gen b_`var' = .
		replace b_`var' = 1 if `var' > 1
		replace b_`var' = 0 if `var' == 1
		replace b_`var' = . if missing(`var') | veteran==0
}

* for pride of service, count as b_var==1 only strongly agree (5) 
gen b_proud = .
	replace b_proud = 0 if proud < 5		// 0 if Less than Most Proud 
	replace b_proud = 1 if proud == 5		// 1 if Most Proud 
	replace b_proud = . if missing(proud) | veteran==0

* for not proud of service, var==1 anyone not strongly agreeing (5) 	
recode b_proud (0=1) (1=0), gen(b_notproud) // Flip to Not Proud = 1







 * Labeling ********************************************************************

label var b_male 				"Male = 1"
label var b_republican 			"Republican = 1"
label var b_under35 			"Under 35 = 1"
label var b_nocollege 			"No College = 1"
label var b_christian 			"Christian = 1"
label var b_authoritarian 		"Authoritarian = 1"
label var b_religious 			"Religious = 1"
label var b_childlaw 			"Childhood Legal Trouble = 1"
label var b_conspiracy 			"Far-Right Conspiracy = 1"
label var b_polarization 		"Political Polarization = 1"
label var b_econconcern 		"Economic Concern = 1"
label var b_hardship 			"Recent Economic Hardship = 1"
label var b_servedgwot 			"Served During GWoT = 1"
label var b_singletour 			"Served 4 years or Less = 1"
label var b_combatdeployment	"Deployed to Combat Area = 1"
label var b_discharged 			"Involuntary Discharge = 1"
label var b_combattrauma 		"Combat Trauma = 1"
label var b_reintegration 		"Trouble Reintegrating = 1"
label var b_disillusioned 		"Disillusioned with Sacrifice = 1"
label var b_unappreciated 		"Believe Service Unappreciated = 1"
label var b_ptsd 				"Service-Related PTSD = 1"
label var b_proud 				"Proud of Service = 1"
label var b_notproud 			"Not Proud of Service = 1"
label var b_insurrect 			"Insurrection Sentiments = 1"	
label var b_polarization 		"Support for Trump = 1"	
label var insurrection_index 	"Insurrection Index"
label var authoritarianism 		"Authoritarian Index"
label var religiosity 			"Religiosity Index"
label var polarization 			"Political Polarization"
label var conspiracy			"Conspiracy Index"
label var combattrauma			"Combat Trauma Index"
label var childlaw 				"Childhood Trouble with the Law"
label var age 					"Age"
label var partyid3 				"Party Identification"
label var veteran 				"Veteran = 1"
label var polarization 			"Support for Trump" 


compress

save vetstudy_jcr_use.dta, replace
